package net.anzhuo.service.impl;

import net.anzhuo.common.entity.PaginationVO;
import net.anzhuo.dao.GsChangeMapper;
import net.anzhuo.entity.GsChange;
import net.anzhuo.service.GsChangeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class GsChangeServiceImpl implements GsChangeService {

	@Autowired
	private GsChangeMapper gsChangeMapper;

	@Override
	public PaginationVO<GsChange> getListWithPage(GsChange gsChange) {
		PaginationVO<GsChange> paginationVO = new PaginationVO<>();
		paginationVO.setList(gsChangeMapper.getListWithPage(gsChange));
		paginationVO.setTotalCount(gsChangeMapper.getCount(gsChange));
		paginationVO.setTotalPage((gsChangeMapper.getCount(gsChange) + gsChange.getPageSize() -1)  / gsChange.getPageSize());
		paginationVO.setPageNo(gsChange.getPageNo());
		return paginationVO;
	}

	@Override
	public GsChange getById(Long id) {
		return gsChangeMapper.getById(id);
	}



	@Override
	public List<GsChange> getList(GsChange gsChange) {
		return gsChangeMapper.getList(gsChange);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void update(GsChange gsChange) {
		gsChangeMapper.update(gsChange);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void save(GsChange gsChange) {
		gsChangeMapper.save(gsChange);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void delete(GsChange gsChange) {
		gsChangeMapper.delete(gsChange);
	}

	@Override
	public List<GsChange> getByMd5(String md5) {
		return gsChangeMapper.getByMd5(md5);
	}
}
